package SOEN_Phase_3;

import junit.framework.TestCase;
import junit.framework.Assert;

import java.awt.event.KeyEvent;

public class NumberFieldValidatorTest extends TestCase {

	public void testKeyTypedKeyEvent() {
		 // Verify it is a valid number, otherwise consume (erase) it
		boolean test1 = false;
		boolean test2 = false;
		boolean test3 = false;
		boolean test4 = false;
		boolean test5 = false;
		
        
		char c = '5';
        if(
            !((c >= '0') && (c <= '9') ||
            (c == KeyEvent.VK_BACK_SPACE) ||
            (c == KeyEvent.VK_DELETE))    )
        {
            test1 = true;
        }
        
        char d = 'g';
        if(
            !((d >= '0') && (d <= '9') ||
            (d == KeyEvent.VK_BACK_SPACE) ||
            (d == KeyEvent.VK_DELETE))    )
        {
            test2 = true;
        }
        
        char n = 'h';
        if(
            !((n >= '0') && (n <= '9') ||
            (n == KeyEvent.VK_BACK_SPACE) ||
            (n == KeyEvent.VK_DELETE))    )
        {
            test3 = true;
        }
        
        char r = 'F';
        if(
            !((r >= '0') && (r <= '9') ||
            (r == KeyEvent.VK_BACK_SPACE) ||
            (r == KeyEvent.VK_DELETE))    )
        {
            test4 = true;
        }
        
        char x = ';';
        if(
            !((r >= '0') && (r <= '9') ||
            (r == KeyEvent.VK_BACK_SPACE) ||
            (r == KeyEvent.VK_DELETE))    )
        {
            test5 = true;
        }
        
        assertTrue("Test1 failed", !test1);
        assertTrue("Test2 failed", test2);
        assertTrue("Test3 failed", test3);
        assertTrue("Test4 failed", test4);
        assertTrue("Test5 failed", test5);
	}
}
